package com.example.demo.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Response <T> implements Serializable {
    private Integer code;
    private String msg;
    private T data;

    public static <T> Response<T> ok(T data){
        Response<T> response = new Response<T>();
        response.setCode(200);
        response.setMsg("completed");
        response.setData(data);
        return response;
    }

    public static <T> Response<T> ok(Integer code, String message) {
        Response<T> response = new Response<T>();
        response.setCode(code);
        response.setMsg(message);
        return response;
    }

    public static <T> Response<T> ok(Integer code, String message, T data) {
        Response<T> response = new Response<T>();
        response.setCode(code);
        response.setMsg(message);
        response.setData(data);
        return response;
    }
}

